package com.androidhelper.module.common.utils;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.androidhelper.module.common.R;

public class DialogUtils {




    public static Dialog createLoadingDialog(Context context, String msg) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.loading, null);// 得到加载view
        // LinearLayout comment_item = (LinearLayout)
        // v.findViewById(R.id.dialog_view);// 加载布局
        TextView tvMsg = (TextView) v.findViewById(R.id.tipTextView);
        tvMsg.setText(TextUtils.isEmpty(msg) ? "正在加载中..." : msg);
        Dialog loadingDialog = new Dialog(context, R.style.loading_dialog);// 创建自定义样式dialog
        loadingDialog.setCancelable(true);// 不可以用“返回键”取消
        Window window = loadingDialog.getWindow();
        // WindowManager.LayoutParams lp = window.getAttributes();
        window.setGravity(Gravity.CENTER);
        loadingDialog.setContentView(v);// 设置布局
        return loadingDialog;
    }

}














